package com.invest.vo;

import com.invest.config.AppProperties;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.constraints.NotNull;

/**
 * <p>注释</p>
 *
 * @author yuyizhao
 * @version v0.1 2016/7/26 Exp
 */
public class WxNewsVO  extends AbstractFileVO{
    @NotNull(message = "分类不能为空")
    private String newsCategory;

    @NotNull(message = "标题不能为空")
    private String title;

    @NotNull(message = "图片文件不能为空")
    private MultipartFile picFile;

    private String detailPage;

    // 真实路劲
    private String picDiskPath;

    private String picUriPath;

    private String detailPageDiskPath;

    private String detailPageUriPath;

    public String getNewsCategory() {
        return newsCategory;
    }

    public void setNewsCategory(String newsCategory) {
        this.newsCategory = newsCategory;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public MultipartFile getPicFile() {
        return picFile;
    }

    public void setPicFile(MultipartFile picFile) {
        this.picFile = picFile;
    }

    public String getDetailPage() {
        return detailPage;
    }

    public void setDetailPage(String detailPage) {
        this.detailPage = detailPage;
    }

    public void build(String crpId, AppProperties fileProperties){

        String picFullName =  randomFileName(AbstractFileVO.FILE_PIC_PREFIX,picFile.getOriginalFilename());
        picDiskPath = getDiskPath(crpId,picFullName,fileProperties);
        picUriPath = getUriPath(crpId,picFullName,fileProperties);
        String detailFuleName =  randomFileName(AbstractFileVO.FILE_HTML_PREFIX,"tmp.html");
        detailPageDiskPath = getDiskPath(crpId,detailFuleName,fileProperties);
        detailPageUriPath = getUriPath(crpId,detailFuleName,fileProperties);
    }

    public String getPicDiskPath() {
        return picDiskPath;
    }

    public void setPicDiskPath(String picDiskPath) {
        this.picDiskPath = picDiskPath;
    }

    public String getPicUriPath() {
        return picUriPath;
    }

    public void setPicUriPath(String picUriPath) {
        this.picUriPath = picUriPath;
    }

    public String getDetailPageDiskPath() {
        return detailPageDiskPath;
    }

    public void setDetailPageDiskPath(String detailPageDiskPath) {
        this.detailPageDiskPath = detailPageDiskPath;
    }

    public String getDetailPageUriPath() {
        return detailPageUriPath;
    }

    public void setDetailPageUriPath(String detailPageUriPath) {
        this.detailPageUriPath = detailPageUriPath;
    }
}
